#!/usr/bin/env node

import { join, dirname } from 'path'
import Index from './Index.js';
import * as grpc from '@grpc/grpc-js';
import API from '@3-/ragapi/API.js'
import Search from './Search.js';

const ROOT = dirname(import.meta.dirname),
  {env} = process


const server = new grpc.Server();

server.addService(API.Rag.service, {
  Index,
  Search
});

server.bindAsync(
 env.GRPC_IP_PORT, 
 grpc.ServerCredentials.createInsecure(), 
 async (err, port) => {
  if (err) {
   console.error("服务器启动失败:", err);
   return;
  }
  console.log(`grpc 0.0.0.0:${port}`);
});
